package ifmo.compiler.task21.entity;

/**
 * Class representing a rational number (fraction)
 *
 * @author byaminov
 */
public class RationalNumber {

    private int numerator;
    private int denominator;

    public RationalNumber(int numerator, int denominator) {
        if (denominator == 0) {
            throw new ArithmeticException("Denominator is zero");
        }
        this.denominator = denominator;
        this.numerator = numerator;
    }

    public int getDenominator() {
        return denominator;
    }

    public int getNumerator() {
        return numerator;
    }

    public float getValue() {
        return ((float) numerator) / denominator;
    }

    public String toString() {
        return numerator + "/" + denominator;
    }
}
